<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>广告分类列表</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container mt-4">
    <h1>广告分类列表</h1>
    <a href="/admin/categories/add" class="btn btn-primary mb-3">添加分类</a>
    <a href="/admin/ads" class="btn btn-secondary mb-3 ms-2">广告管理</a>

    <table class="table table-striped">
        <thead>
        <tr>
            <th>ID</th>
            <th>名称</th>
            <th>描述</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="category : ${categories}">
            <td th:text="${category.id}"></td>
            <td th:text="${category.name}"></td>
            <td th:text="${category.description}"></td>
            <td th:text="${#temporals.format(category.createdAt, 'yyyy-MM-dd HH:mm')}"></td>
            <td>
                <a th:href="@{/admin/categories/edit/{id}(id=${category.id})}" class="btn btn-sm btn-warning">编辑</a>
                <a th:href="@{/admin/categories/delete/{id}(id=${category.id})}" class="btn btn-sm btn-danger" onclick="return confirm('确定删除这个分类吗？')">删除</a>
            </td>
        </tr>
        </tbody>
    </table>
</div>
</body>
</html>